-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: calculate timestamp and block number tacking account execution mode (execution vs validate) #401
Conversation
@@ -136,9 +137,11 @@ where | |||
let syscall_handler = self.deprecated_syscall_handler.read().await; | |||
|
|||
let block_number = syscall_handler.block_info.block_number; | |||
let rounded_block_number = (block_number.0 / VALIDATE_BLOCK_NUMBER_ROUNDING ) * VALIDATE_BLOCK_NUMBER_ROUNDING; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you use prev_multiple_of
instead?
@@ -15,6 +15,7 @@ use crate::cairo_types::syscalls::{ | |||
TxInfo, | |||
}; | |||
use crate::starknet::starknet_storage::PerContractStorage; | |||
use crate::execution::constants::{VALIDATE_BLOCK_NUMBER_ROUNDING, VALIDATE_TIMESTAMP_ROUNDING}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We already discussed this, but these should be able to come from the constants in cairo-lang
. We should do that if at all possible, but if not we should leave a comment about that here.
let execution_info_ptr = execution_helper | ||
.call_execution_info_ptr | ||
.ok_or(HintError::SyscallError("Execution info pointer not set".to_string().into_boxed_str()))?; | ||
let block_info_pointer = vm.get_relocatable((execution_info_ptr + ExecutionInfo::block_info_offset())?)?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Super nit: we usually _ptr
instead of _pointer
let tx_version = TransactionVersion::ZERO; | ||
let tx_version = TransactionVersion::THREE; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this necessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am also curious about this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Left a couple small nits.
Also, it might be good to document the behavior of the validation mode briefly in the functions if it seems useful.
Co-authored-by: Stephen Shelton <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
let tx_version = TransactionVersion::ZERO; | ||
let tx_version = TransactionVersion::THREE; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am also curious about this.
Problem: Some blocks were failing because the get_block_number and get_block_timestamp were retrieving different values than the SNOS was expecting.
This is related to the fact that two modes of execution exist: Execute (were the expected behaviour is to get the actual block number and timestamp) and Validate (were the expectation is to get an rounding of them)
Fix: modify the given syscalls to fetch the blockInfo from the ExecutionInfo struct from SNOS